package cn.edu.zut.cs.Controller;

import cn.edu.zut.cs.Business.SaleService;
import cn.edu.zut.cs.Model.Info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class InfoController {
    SaleService service;
    @RequestMapping(value = "/index.html")
    public String index(){
        return "index";
    }
    @RequestMapping(value = "/infolist.html")
    public String infolist(HttpServletRequest request){

        request.getSession().setAttribute("infos",service.queryAll());
        return "infolist";
    }

    @RequestMapping(value = "/report.html")
    public String report(){
        return "report";
    }
    @RequestMapping(value = "/insert.html")
    public String insert(HttpServletRequest request, Info info){
        service.insert(info);
        request.getSession().setAttribute("infos",service.queryAll());
        return "infolist";
    }
    @Autowired
    public void setService(SaleService service) {
        this.service = service;
    }
}
